package com.kevin.entity;

import java.math.BigDecimal;
import java.util.Date;

import org.codehaus.jackson.map.annotate.JsonDeserialize;

import com.kevin.core.util.DateUtils;

import freemarker.template.utility.DateUtil;

public class DayK implements Comparable<DayK>{
    private Long id;

    private String symbol;

    private Long volume;

    private BigDecimal open;

    private BigDecimal high;

    private BigDecimal close;

    private BigDecimal low;

    private BigDecimal chg;

    private BigDecimal percent;

    private BigDecimal turnrate;

    private BigDecimal ma5;

    private BigDecimal ma10;

    private BigDecimal ma20;

    private BigDecimal ma30;

    private BigDecimal dif;

    private BigDecimal dea;

    private BigDecimal macd;

    private Date time;
    
    private Long lossVolume;
    
    private BigDecimal lossVolumePercent;
    
    private String timeStr;
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getSymbol() {
        return symbol;
    }

    public void setSymbol(String symbol) {
        this.symbol = symbol == null ? null : symbol.trim();
    }

    public Long getVolume() {
        return volume;
    }

    public void setVolume(Long volume) {
        this.volume = volume;
    }

    public BigDecimal getOpen() {
        return open;
    }

    public void setOpen(BigDecimal open) {
        this.open = open;
    }

    public BigDecimal getHigh() {
        return high;
    }

    public void setHigh(BigDecimal high) {
        this.high = high;
    }

    public BigDecimal getClose() {
        return close;
    }

    public void setClose(BigDecimal close) {
        this.close = close;
    }

    public BigDecimal getLow() {
        return low;
    }

    public void setLow(BigDecimal low) {
        this.low = low;
    }

    public BigDecimal getChg() {
        return chg;
    }

    public void setChg(BigDecimal chg) {
        this.chg = chg;
    }

    public BigDecimal getPercent() {
        return percent;
    }

    public void setPercent(BigDecimal percent) {
        this.percent = percent;
    }

    public BigDecimal getTurnrate() {
        return turnrate;
    }

    public void setTurnrate(BigDecimal turnrate) {
        this.turnrate = turnrate;
    }

    public BigDecimal getMa5() {
        return ma5;
    }

    public void setMa5(BigDecimal ma5) {
        this.ma5 = ma5;
    }

    public BigDecimal getMa10() {
        return ma10;
    }

    public void setMa10(BigDecimal ma10) {
        this.ma10 = ma10;
    }

    public BigDecimal getMa20() {
        return ma20;
    }

    public void setMa20(BigDecimal ma20) {
        this.ma20 = ma20;
    }

    public BigDecimal getMa30() {
        return ma30;
    }

    public void setMa30(BigDecimal ma30) {
        this.ma30 = ma30;
    }

    public BigDecimal getDif() {
        return dif;
    }

    public void setDif(BigDecimal dif) {
        this.dif = dif;
    }

    public BigDecimal getDea() {
        return dea;
    }

    public void setDea(BigDecimal dea) {
        this.dea = dea;
    }

    public BigDecimal getMacd() {
        return macd;
    }

    public void setMacd(BigDecimal macd) {
        this.macd = macd;
    }

    public Date getTime() {
        return time;
    }

    @JsonDeserialize(using=com.stock.DateDerializer.class)
    public void setTime(Date time) {
        this.time = time;
    }
    

	public Long getLossVolume() {
		return lossVolume;
	}

	public void setLossVolume(Long lossVolume) {
		this.lossVolume = lossVolume;
	}

	public BigDecimal getLossVolumePercent() {
		return lossVolumePercent;
	}

	public void setLossVolumePercent(BigDecimal lossVolumePercent) {
		this.lossVolumePercent = lossVolumePercent;
	}
	
	

//	@Override
//	public String toString() {
//		return "DayK [id=" + id + ", symbol=" + symbol + ", volume=" + volume
//				+ ", open=" + open + ", high=" + high + ", close=" + close
//				+ ", low=" + low + ", chg=" + chg + ", percent=" + percent
//				+ ", turnrate=" + turnrate + ", ma5=" + ma5 + ", ma10=" + ma10
//				+ ", ma20=" + ma20 + ", ma30=" + ma30 + ", dif=" + dif
//				+ ", dea=" + dea + ", macd=" + macd + ", time=" + time
//				+ ", lossVolume=" + lossVolume + ", lossVolumePercent="
//				+ lossVolumePercent + "]";
//	}
	

	public String getTimeStr() {
		if(this.time!=null){
			return DateUtils.formatDate(this.time,DateUtils.DATE_FORMAT);
		}else{
			return "";
		}
	}

	public void setTimeStr(String timeStr) {
		this.timeStr = timeStr;
	}

	@Override
	public int compareTo(DayK o) {
		if(this.getLossVolume()==null){
			this.setLossVolume(0l);
		}
		if(o.getLossVolume()==null){
			o.setLossVolume(0l);
		}
		System.out.println(this.getLossVolume()+","+this.getLossVolume());
		return this.getLossVolume().compareTo(o.getLossVolume());
	}

	@Override
	public String toString() {
		return "DayK [open=" + open + ", high=" + high + ", close=" + close
				+ ", low=" + low + ", percent=" + percent + ", timeStr=" + this.getTimeStr()
				+ ", lossVolume=" + lossVolume + "]";
	}
	
	
}